<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<meta name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

    <meta name="author" content="WD">





<title>C51单片机学习笔记(二)——花样流水灯的实现 | WD&#39;s blog</title>



    <link rel="icon" href="/favicon1.ico">




    <!-- stylesheets list from _config.yml -->
    
    <link rel="stylesheet" href="/css/style.css">
    



    <!-- scripts list from _config.yml -->
    
    <script src="/js/script.js"></script>
    
    <script src="/js/tocbot.min.js"></script>
    
    <script src="/js/snow.js"></script>
    



    
    
        
    


<meta name="generator" content="Hexo 5.4.0"></head>
<body>
    <div class="wrapper">
        <header>
    <nav class="navbar">
        <div class="container">
            <div class="navbar-header header-logo"><a href="/">WD&#39;s Blog</a></div>
            <div class="menu navbar-right">
                
                    <a class="menu-item" href="/archives">Posts</a>
                
                    <a class="menu-item" href="/category">Categories</a>
                
                    <a class="menu-item" href="/tag">Tags</a>
                
                    <a class="menu-item" href="/about">About</a>
                
                <input id="switch_default" type="checkbox" class="switch_default">
                <label for="switch_default" class="toggleBtn"></label>
            </div>
        </div>
    </nav>

    
    <nav class="navbar-mobile" id="nav-mobile">
        <div class="container">
            <div class="navbar-header">
                <div>
                    <a href="/">WD&#39;s Blog</a><a id="mobile-toggle-theme">·&nbsp;Light</a>
                </div>
                <div class="menu-toggle" onclick="mobileBtn()">&#9776; Menu</div>
            </div>
            <div class="menu" id="mobile-menu">
                
                    <a class="menu-item" href="/archives">Posts</a>
                
                    <a class="menu-item" href="/category">Categories</a>
                
                    <a class="menu-item" href="/tag">Tags</a>
                
                    <a class="menu-item" href="/about">About</a>
                
            </div>
        </div>
    </nav>

</header>
<script>
    var mobileBtn = function f() {
        var toggleMenu = document.getElementsByClassName("menu-toggle")[0];
        var mobileMenu = document.getElementById("mobile-menu");
        if(toggleMenu.classList.contains("active")){
           toggleMenu.classList.remove("active")
            mobileMenu.classList.remove("active")
        }else{
            toggleMenu.classList.add("active")
            mobileMenu.classList.add("active")
        }
    }
</script>
        <div class="main">
            <div class="container">
    
    
        <div class="post-toc">
    <div class="tocbot-list">
    </div>
    <div class="tocbot-list-menu">
        <a class="tocbot-toc-expand" onclick="expand_toc()">Expand all</a>
        <a onclick="go_top()">Back to top</a>
        <a onclick="go_bottom()">Go to bottom</a>
    </div>
</div>

<script>
    document.ready(
        function () {
            tocbot.init({
                tocSelector: '.tocbot-list',
                contentSelector: '.post-content',
                headingSelector: 'h1, h2, h3, h4, h5',
                collapseDepth: 1,
                orderedList: false,
                scrollSmooth: true,
            })
        }
    )

    function expand_toc() {
        var b = document.querySelector(".tocbot-toc-expand");
        tocbot.init({
            tocSelector: '.tocbot-list',
            contentSelector: '.post-content',
            headingSelector: 'h1, h2, h3, h4, h5',
            collapseDepth: 6,
            orderedList: false,
            scrollSmooth: true,
        });
        b.setAttribute("onclick", "collapse_toc()");
        b.innerHTML = "Collapse all"
    }

    function collapse_toc() {
        var b = document.querySelector(".tocbot-toc-expand");
        tocbot.init({
            tocSelector: '.tocbot-list',
            contentSelector: '.post-content',
            headingSelector: 'h1, h2, h3, h4, h5',
            collapseDepth: 1,
            orderedList: false,
            scrollSmooth: true,
        });
        b.setAttribute("onclick", "expand_toc()");
        b.innerHTML = "Expand all"
    }

    function go_top() {
        window.scrollTo(0, 0);
    }

    function go_bottom() {
        window.scrollTo(0, document.body.scrollHeight);
    }

</script>
    

    
    <article class="post-wrap">
        <header class="post-header">
            <h1 class="post-title">C51单片机学习笔记(二)——花样流水灯的实现</h1>
            
                <div class="post-meta">
                    
                        Author: <a itemprop="author" rel="author" href="/about/">WD</a>
                     &nbsp;

                    
                        <span class="post-time">
                        Date: <a href="#">March 28, 2019&nbsp;&nbsp;18:35:04</a>
                        </span>
                     &nbsp;
                    
                        <span class="post-category">
                    Category:
                            
                                <a href="/categories/C51%E5%8D%95%E7%89%87%E6%9C%BA/">C51单片机</a>
                            
                        </span>
    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <br>
    <span id="busuanzi_container_site_pv">总阅读量:<a href="#"><span id="busuanzi_value_page_pv"></span></a>次</span>&nbsp;
    <span class="post-count">文章字数:<a href="#">1.5k</span></a>&nbsp;
     <span class="post-count">阅读时长:<a href="#">6</span>min</a>
                    
                </div>
            
        </header>

        <div class="post-content">
            <div id="article_content" class="article_content clearfix">
<p></p><div class="toc"><h2><a name="t1"></a>文章目录</h2><ul><ul><ul><li><a href="#1_2" rel="nofollow" data-token="b48c7a9fe647fc89d1ceb4ca737597e7" target="_self">1.单片机引脚、晶振、复位的作用</a></li><li><a href="#2_19" rel="nofollow" data-token="18ee178ea60a93e3ed4d34b29c1af946" target="_self">2.流水灯原理图</a></li><li><a href="#3_25" rel="nofollow" data-token="eaf0bb09b8b73940f91f5504f75f61af" target="_self">3.单片机的周期</a></li><li><a href="#4_32" rel="nofollow" data-token="dbca694808bf1d8b3c18dc9eb73126fe" target="_self">4.延时函数的编写</a></li><li><a href="#5_53" rel="nofollow" data-token="795da4d268d2d4dfcc4064e9aa08e803" target="_self">5.使用“位操作”控制流水灯</a></li><li><a href="#6IO_88" rel="nofollow" data-token="432c64ac598b68514d9d6acbab46d8ca" target="_self">6.使用字节控制（并行I/O口控制）流水灯</a></li><li><a href="#7_117" rel="nofollow" data-token="0e78511af211a5033b29786589327e43" target="_self">7.使用数组控制流水灯</a></li></ul></ul></ul></div><p></p>
<h2><a name="t2"></a><a id="1_2"></a>1.单片机引脚、晶振、复位的作用</h2>
<p><img src="https://img-blog.csdnimg.cn/20190327152731464.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<blockquote>
<ul>
<li>复位电路：，复位是单片机的初始化操作。单片机启动时都需要先付薇，其作用是“清零”，也就是CPU和其他部件处于一个确定的初始状态，并从这个初始状态开始。</li>
<li>复位实质上是单片机的复位脚保持很短时间的高电平，按键复位就是通过按键接高电平（按一下的时间已经足够）</li>
<li>时钟电路（晶振）：产生时间信号，使单片机按照一定的时间规律进行指令，晶振频率越高，时钟信号的周期就小，单片机运行也就越快。</li>
</ul>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/20190327152905201.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<ul>
<li>
<p>32个I/O口</p>
</li>
<li>
<p>P1.0 ~ P1.7 对应1 ~ 8 号引脚</p>
</li>
<li>
<p>P2.0 ~ P2.7 对应21 ~ 28 号引脚</p>
</li>
<li>
<p>P3.0 ~ P3.7 对应10 ~ 17 号引脚</p>
</li>
<li>
<p>P0.0 ~ P0.7 对应39 ~ 32 号引脚<br>
其中，P3口除作标准I/O口外，还可以将每一位用于第二功能：<br>
<img src="https://img-blog.csdnimg.cn/20190327153151250.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>
其他引脚功能：<br>
<img src="https://img-blog.csdnimg.cn/20190327153210268.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
</li>
</ul>
<h2><a name="t3"></a><a id="2_19"></a>2.流水灯原理图</h2>
<p><img src="https://img-blog.csdnimg.cn/20190327154157706.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMTgxNTky,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<ul>
<li>D1~D8为发光二极管（LED），由于LED工作时能承受的电流很小，所以后面接在PR1上，PR1是一个排阻，电阻的大小一般为100Ω左右，以防止电流过大击穿二极管，P20-P27是接单片机的P2.0-P2.7的引脚，Vcc接高电平，所以电流从右向左流，要想LED导通，仅需引脚处为低电平，两端形成电位差，LED被点亮</li>
<li>所以通过编程控制P2口的8个引脚，使他们周期性的输出高电平、低电平并延时，即可使LED闪烁，构成流水灯。</li>
</ul>
<h2><a name="t4"></a><a id="3_25"></a>3.单片机的周期</h2>
<ul>
<li>时钟周期：</li>
</ul>
<blockquote>
<p>也称振荡周期，是时钟频率的倒数，就看晶振是多少HZ的，若是12MHZ的，时钟周期就是1/12微秒，他是单片机中最小的时间单位，在一个时钟周期内单片机仅能完成一个最基本的动作。</p>
</blockquote>
<ul>
<li>机器周期：</li>
</ul>
<blockquote>
<p>是单片机的基本操作周期，为时钟周期的12倍，在一个机器周期内可以完成一个取指令的动作。</p>
</blockquote>
<ul>
<li>指令周期：</li>
</ul>
<blockquote>
<p>指单片机完成一条指令所需的时间，一般为4个机器周期。</p>
</blockquote>
<h2><a name="t5"></a><a id="4_32"></a>4.延时函数的编写</h2>

<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">delay</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">unsigned</span> <span class="keyword">int</span> x,y;       <span class="comment">//定义无符号的int型x，y</span></span><br><span class="line">	<span class="keyword">for</span>(x = <span class="number">1000</span>;x&gt;<span class="number">0</span>;x--)</span><br><span class="line">		<span class="keyword">for</span>(y=<span class="number">110</span>;y&gt;<span class="number">0</span>;y--);</span><br><span class="line">	</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>每执行一次x-1，y就要从110逐步-1，直到减小到0，x共要自减1000次，总耗时约为1秒（这个时间会有误差，如果要精确延时，后面讲到中断再说明）</li>
<li>如果一个程序里需要不同的延时时间，就需要用带参数的延时函数</li>
</ul>

<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">delay</span><span class="params">(<span class="keyword">unsigned</span> <span class="keyword">int</span> z)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">unsigned</span> <span class="keyword">int</span> x,y;       <span class="comment">//定义无符号的int型x，y</span></span><br><span class="line">	<span class="keyword">for</span>(x = z;x&gt;<span class="number">0</span>;x--)</span><br><span class="line">		<span class="keyword">for</span>(y=<span class="number">110</span>;y&gt;<span class="number">0</span>;y--);</span><br><span class="line">	</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2><a name="t6"></a><a id="5_53"></a>5.使用“位操作”控制流水灯</h2>
<ul>
<li>编程思路：“位操作”就是控制单独的一个I/O口，使该引脚输出高电平或低电平，来驱动与该引脚相连的元器件发生相应的动作。</li>
</ul>

<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;reg52.h&gt;</span></span></span><br><span class="line">sbit led0 = P2^<span class="number">0</span>;  <span class="comment">// sbit是定义位的关键字，一个引脚就是一位，P2^0代表P2.0引脚，以此类推</span></span><br><span class="line">sbit led1 = P2^<span class="number">1</span>;</span><br><span class="line">sbit led1 = P2^<span class="number">2</span>;</span><br><span class="line">sbit led1 = P2^<span class="number">3</span>;</span><br><span class="line">sbit led1 = P2^<span class="number">4</span>;</span><br><span class="line">sbit led1 = P2^<span class="number">5</span>;</span><br><span class="line">sbit led1 = P2^<span class="number">6</span>;</span><br><span class="line">sbit led1 = P2^<span class="number">7</span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">delay</span><span class="params">(unsigend z)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	led0 = <span class="number">0</span>;   <span class="comment">//此时P2.0引脚为低电平，LED点亮</span></span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">500</span>);   <span class="comment">//延时500毫秒</span></span><br><span class="line">	led0 = <span class="number">1</span>;    <span class="comment">//将P2.0引脚为低电平，LED熄灭</span></span><br><span class="line">	</span><br><span class="line">	led1 = <span class="number">0</span>;</span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">500</span>);</span><br><span class="line">	led1 = <span class="number">1</span>;</span><br><span class="line">	led2 = <span class="number">0</span>;<span class="built_in">delay</span>(<span class="number">500</span>);led2=<span class="number">1</span>;led3=<span class="number">0</span>;<span class="built_in">delay</span>(<span class="number">500</span>);led3=<span class="number">1</span>;</span><br><span class="line">	led4 = <span class="number">0</span>;<span class="built_in">delay</span>(<span class="number">500</span>);led4=<span class="number">1</span>;led5=<span class="number">0</span>;<span class="built_in">delay</span>(<span class="number">500</span>);led5=<span class="number">1</span>;</span><br><span class="line">	led6 = <span class="number">0</span>;<span class="built_in">delay</span>(<span class="number">500</span>);led6=<span class="number">1</span>;led7=<span class="number">0</span>;<span class="built_in">delay</span>(<span class="number">500</span>);led7=<span class="number">1</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">delay</span><span class="params">(<span class="keyword">unsigned</span> z)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">unsigned</span> x,y;</span><br><span class="line">	<span class="keyword">for</span>(x = z;x&gt;<span class="number">0</span>;x--)</span><br><span class="line">		<span class="keyword">for</span>(y = <span class="number">110</span>;y&gt;<span class="number">0</span>;y--);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<blockquote>
<ul>
<li>按照上一篇的烧写方法就可以烧入单片机，观察到流水灯闪烁。</li>
</ul>
</blockquote>
<h2><a name="t7"></a><a id="6IO_88"></a>6.使用字节控制（并行I/O口控制）流水灯</h2>
<ul>
<li>编程思路：51系列单片机是8位单片机，每一组端口共有8个引脚，每个引脚可输出一个电平（0/1），一组端口可同时输出8个电平，正好构成一个字节。用字节操作来控制同时点亮几个流水灯的流动，要比位操作简单的多，即要点亮D2，D4，D6，D8，只需要P2端口从高位P2.7-P2.0 输出 0101 0101，将这8位二进制数转化为十六进制位0X55，只需要P2 = 0X55就行了。</li>
</ul>

<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;reg52.h&gt;</span></span></span><br><span class="line"><span class="meta">#defined LED P2;  <span class="comment">//宏定义 LED表示端口P2</span></span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">delay</span><span class="params">(<span class="keyword">unsigned</span> <span class="keyword">int</span> z)</span><span class="comment">//延时函数的另一种写法</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">while</span>(z--);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	LED = <span class="number">0</span>xlf;    <span class="comment">//0xlf = 0001 1111</span></span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">30000</span>);     </span><br><span class="line">	LED = <span class="number">0x8f</span>;     <span class="comment">//0x8f = 1000 1111   </span></span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">30000</span>);</span><br><span class="line">	LED = <span class="number">0xc7</span>;     <span class="comment">//0xc7 = 1100 0111</span></span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">30000</span>);</span><br><span class="line">	LED = <span class="number">0xe3</span>;    <span class="comment">//0xe3 = 1110 0011 </span></span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">30000</span>);</span><br><span class="line">	LED = <span class="number">0xf1</span>;     <span class="comment">//0xf1 = 1111 0001</span></span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">30000</span>);</span><br><span class="line">	LED = <span class="number">0xf8</span>;  <span class="comment">//0xf8 = 1111 1000</span></span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">30000</span>);</span><br><span class="line">	LED = <span class="number">0x7c</span>;   <span class="comment">//0x7c = 0111 1100</span></span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">30000</span>);</span><br><span class="line">	LED = <span class="number">0x3e</span>;  <span class="comment">//0x3e = 0011 1110</span></span><br><span class="line">	<span class="built_in">delay</span>(<span class="number">30000</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2><a name="t8"></a><a id="7_117"></a>7.使用数组控制流水灯</h2>
<ul>
<li>定义一个char类型（一个字节）的数组存放每个十六进制数，这样用一个for循环就可以循环赋值并延时</li>
</ul>

<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;reg52.h&gt;</span></span></span><br><span class="line"><span class="keyword">unsigned</span> <span class="keyword">char</span> table[] = &#123;<span class="number">0xfe</span>,<span class="number">0xfd</span>,<span class="number">0xfb</span>,<span class="number">0xf7</span>,<span class="number">0xef</span>,<span class="number">0xdf</span>,<span class="number">0xbf</span>,<span class="number">0x7f</span>&#125;;<span class="comment">//点亮第1、2、3、4···个灯的十六进制代码传入</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">delay</span><span class="params">(<span class="keyword">unsigned</span> <span class="keyword">int</span> z)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">unsigned</span> <span class="keyword">int</span> x,y;</span><br><span class="line">	<span class="keyword">for</span>(x=z;x&gt;<span class="number">0</span>;x--)</span><br><span class="line">		<span class="keyword">for</span>(y=<span class="number">110</span>;y&gt;<span class="number">0</span>;y--);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;<span class="number">8</span>;i++)</span><br><span class="line">	&#123;</span><br><span class="line">		P2 = table[i];</span><br><span class="line">		<span class="built_in">delay</span>(<span class="number">500</span>);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</div>

        </div>

        
            <section class="post-copyright">
                
                    <p class="copyright-item">
                        <span>Author:</span>
                        <span><a href="/about/">WD</a></span>
                    </p>
                
                
                    <p class="copyright-item">
                        <span>Permalink:</span>
                        <span><a href="https://did321.gitee.io/2019/03/28/C51%E5%8D%95%E7%89%87%E6%9C%BA%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E4%BA%8C-%E2%80%94%E2%80%94%E8%8A%B1%E6%A0%B7%E6%B5%81%E6%B0%B4%E7%81%AF%E7%9A%84%E5%AE%9E%E7%8E%B0/">https://did321.gitee.io/2019/03/28/C51%E5%8D%95%E7%89%87%E6%9C%BA%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E4%BA%8C-%E2%80%94%E2%80%94%E8%8A%B1%E6%A0%B7%E6%B5%81%E6%B0%B4%E7%81%AF%E7%9A%84%E5%AE%9E%E7%8E%B0/</a></span>
                    </p>
                
                
                    <p class="copyright-item">
                        <span>License:</span>
                        <span>Copyright (c) 2022 <a target="_blank" rel="noopener" href="http://creativecommons.org/licenses/by-nc/4.0/">CC-BY-NC-4.0</a> LICENSE</span>
                    </p>
                
                
                     <p class="copyright-item">
                         <span>Slogan:</span>
                         <span><a href="#">The blog is my giant.</a></span>
                     </p>
                

            </section>
        
        <section class="post-tags">
            <div>
                <span>Tag(s):</span>
                <span class="tag">
                    
                    
                        <a href="/tags/C51%E5%8D%95%E7%89%87%E6%9C%BA/"># C51单片机</a>
                    
                        
                </span>
            </div>
            <div>
                <a href="javascript:window.history.back();">back</a>
                <span>· </span>
                <a href="/">home</a>
            </div>
        </section>
        <section class="post-nav">
            
                <a class="prev" rel="prev" href="/2019/03/29/C51%E5%8D%95%E7%89%87%E6%9C%BA%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E4%B8%89-%E2%80%94%E2%80%94%E6%8C%89%E9%94%AE%E5%AF%B9%E7%81%AF%E3%80%81%E8%9C%82%E9%B8%A3%E5%99%A8%E7%AD%89%E5%99%A8%E4%BB%B6%E7%9A%84%E6%8E%A7%E5%88%B6/">C51单片机学习笔记(三)——按键对灯、蜂鸣器等器件的控制</a>
            
            
            <a class="next" rel="next" href="/2019/03/25/C51%E5%8D%95%E7%89%87%E6%9C%BA%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E4%B8%80-%E2%80%94%E2%80%94%E6%90%AD%E5%BB%BA%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E5%8F%8A%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7/">C51单片机学习笔记(一)——搭建开发环境及烧写工具</a>
            
        </section>
        <br>
        <br>
    
    <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
    <div id="vcomments"></div>
    <script>
        new Valine({
    el: '#vcomments' ,

    appId: 'JvFy3ebVLo2rUYgHaMweJyXX-MdYXbMMI',
    appKey: 'TCFxfjDAM8UmERPEgYXJmT40',
    serverURLs: 'https://JvFy3ebV.api.lncldglobal.com', 
    placeholder: '----评论区----留下你的评论，作者会定期回复！在昵称处填写QQ号可自动获取邮箱和QQ头像（保护QQ邮箱隐私）',
    enableQQ: true,
    requiredFields: ['nick'],
});
    </script>

    </article>
</div>

        </div>
        <footer id="footer" class="footer">
    <div class="copyright">
        <span>© WD | Powered by <a href="https://hexo.io" target="_blank">Hexo</a> & <a href="https://github.com/Siricee/hexo-theme-Chic" target="_blank">Chic</a></span>
    </div>
</footer>

    </div>
</body>

</html>
